<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <title>BenimEtum</title>
	  <META name="Author" content="Ethem Cem Özkan"/>
          <h:outputStylesheet library="css" name="style.css"  />
          <h:outputScript library="js" name="benimetum.js" />
    </h:head>
    <f:view contentType="text/html" encoding="UTF-8">
    <h:body>
        <p:ajaxStatus rendered="#{HomePageBean.status==true}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  
                                
    <p:dialog modal="true" widgetVar="statusDialog" header="Yükleniyor"   
		  draggable="false" closable="false" resizable="false">  
	  <p:graphicImage value="/img/ajaxloadingbar.gif" />  
    </p:dialog> 
	  <h:form>
            <p:menubar style="float: right;">
                <p:menuitem rendered="#{HomePageBean.logon==true}">
                            <c:if test="#{HomePageBean.logon}">
                            <c:if test="#{HomePageBean.userIsTeacher()==true}">
                                <h:commandLink action="#{HomePageBean.clickTeacher()}">
                                        <f:setPropertyActionListener value="#{HomePageBean.user}" target="#{TeacherBean.target}"/>
                                        <h:graphicImage url="#{HomePageBean.profilePicture()}" height="50" width="50"/>
                                </h:commandLink>	
                            </c:if>
                            <c:if test="#{HomePageBean.userIsTeacher()==false}">
                                <h:commandLink action="#{HomePageBean.clickStudent()}">
                                <f:setPropertyActionListener value="#{HomePageBean.user}" target="#{StudentBean.target}"/>
                                    <h:graphicImage url="#{HomePageBean.profilePicture()}" height="50" width="50"/>				    
                                </h:commandLink>	
                            </c:if>
                            </c:if>
                </p:menuitem>
                <p:menuitem rendered="#{HomePageBean.logon==true}">
                        <c:if test="#{HomePageBean.logon}">
                        <c:if test="#{HomePageBean.userIsTeacher()==true}">
                            <p:commandLink value="#{HomePageBean.welcomeText()}" action="#{HomePageBean.clickTeacher()}" ajax="false">
                                <f:setPropertyActionListener value="#{HomePageBean.user}" target="#{TeacherBean.target}"/>
                            </p:commandLink>	
                        </c:if>
                        <c:if test="#{HomePageBean.userIsTeacher()==false}">
                                <p:commandLink value="#{HomePageBean.welcomeText()}" action="#{HomePageBean.clickStudent()}" ajax="false">
                                <f:setPropertyActionListener value="#{HomePageBean.user}" target="#{StudentBean.target}"/>
                        </p:commandLink>	
                        </c:if>
                        </c:if>
                </p:menuitem>
                <p:menuitem rendered="#{HomePageBean.logon==false}">
                        <p:commandButton  id="girislabel" value="#{HomePageBean.girisButtonLabel}" actionListener="#{HomePageBean.clickGiris()}"  update="girislabel,:login" />
                </p:menuitem>
                <p:menuitem rendered="#{HomePageBean.logon==true}">
                        <p:commandButton value="Kontrol Panel" actionListener="#{HomePageBean.clickControlPanel()}" ajax="false"/>
                </p:menuitem>
                <p:menuitem rendered="#{HomePageBean.logon==true}">
                        <p:commandButton value="Çıkış Yap" actionListener="#{HomePageBean.logout()}" ajax="false"/>
                </p:menuitem>    
            </p:menubar>
	  </h:form>
	  <p:panel id="login" visible="#{HomePageBean.loginPanel==true}" style="width: auto;height: auto; float: right;">
			 <h:form>
			  <h:panelGrid columns="2">
				<h:outputLabel value="Kullanıcı Adı*: "/>
				<p:inputText required="true" value="#{HomePageBean.username}"/>
				<h:outputLabel value="Şifre*: "/>
				<p:password feedback="false" required="true" value="#{HomePageBean.password}"/>
				<p:commandButton ajax="false" value="Giriş Yap" action="#{HomePageBean.login()}"/>
				<h:outputLabel rendered="#{HomePageBean.errorLogin==false}" value="#{HomePageBean.errorMessage}"/>
			  </h:panelGrid>
		</h:form>
		</p:panel>
	  <h:form enctype="multipart/form-data" prependId="false" acceptcharset="UTF-8">
    <h:panelGrid columns="2">
                <h:graphicImage height="150" width="150" url="img/logo.JPG" title="BenimEtum" style="float: left"/>
    </h:panelGrid>
                        <p:menubar>
                            <p:menuitem action="#{HomePageBean.clickHomePage()}" value="Anasayfa" ajax="false" update="sayfaalt"/>
                            <p:menuitem rendered="#{HomePageBean.logon==true}" action="#{HomePageBean.clickSearch()}" value="Ara" ajax="false" update="sayfaalt"/>
                            <p:submenu rendered="#{HomePageBean.logon==true}" label="Sınav Programları">
                                <p:menuitem url="http://radyo.etu.edu.tr" disabled="true" value="Vize" ajax="false" />
                                <p:menuitem onclick="finalprogram.show();" value="Final"/>
                            </p:submenu>
                            <p:menuitem url="https://mail.etu.edu.tr/rc/" value="Webmail" ajax="false" />
                            <p:submenu label="Faydalı Linkler">
                                <p:menuitem url="http://radyo.etu.edu.tr" value="RadyoEtu" ajax="false" />
                                <p:menuitem url="http://www.etuportal.com" value="EtuPortal" ajax="false"/>
                            </p:submenu>
                        </p:menubar>
              <h:panelGrid columnClasses="column1,column2" width="100%" columns="2">
                  <h:column >
                      <p:menu rendered="#{HomePageBean.logon==true}" type="tiered">
                            <p:submenu rendered="#{HomePageBean.logon==true}" label="Derslerim">
                                <c:if test="#{HomePageBean.logon==true}">
                                    <c:forEach var="course" items="#{HomePageBean.courses}">
                                        <p:menuitem  value="#{course.NAME}" ajax="false" action="#{HomePageBean.clickCourse()}">
                                                <f:setPropertyActionListener value="#{course}" target="#{CourseBean.target}"/>
                                        </p:menuitem>
                                </c:forEach>
                                </c:if>
                            </p:submenu>
                              <p:submenu rendered="#{HomePageBean.logon==true}" label="Gruplarım" >
                                  <p:submenu rendered="#{HomePageBean.logon==true}" label="Üye Oldugum Gruplar">
                                         <c:if test="#{HomePageBean.logon==true}">    
                                             <c:forEach var="community" items="#{CommunityBean.memberCommuniy}">
                                              <p:menuitem  value="#{community.name}" ajax="false" action="#{HomePageBean.clickMyCommunitys()}" update="sayfaalt">
                                              <f:setPropertyActionListener value="#{community}" target="#{CommunityBean.target}"/>
	                        </p:menuitem>
                                          </c:forEach>      
                                      </c:if>
                                  </p:submenu>         
                                         <p:menuitem rendered="#{HomePageBean.logon==true}" action="#{HomePageBean.clickJoinCommunity()}" value="Bir Gruba Üye Ol" update="sayfaalt" style="word-spacing: inherit">
                                            <f:setPropertyActionListener value="#{community}" target="#{CommunityBean.target}"/></p:menuitem>
                                        <p:menuitem rendered="#{HomePageBean.logon==true}" action="#{HomePageBean.clickCreateNewCommunity()}" value="Yeni Grup Oluştur" update="sayfaalt" style="word-spacing: inherit">
                                            <f:setPropertyActionListener value="#{community}" target="#{CommunityBean.target}"/></p:menuitem>
                              </p:submenu>
                                <p:submenu rendered="#{HomePageBean.logon==true}" label="Forumlarım">
                                        <c:if test="#{HomePageBean.logon==true}">
                                            <c:forEach var="forum" items="#{HomePageBean.studentForum()}">
                                                <p:menuitem  value="#{forum.name()}" action="#{HomePageBean.clickForum()}" ajax="false" update="sayfaalt">
                                                        <f:setPropertyActionListener value="#{forum}" target="#{ForumBean.target}"/>
                                                </p:menuitem>
                                            </c:forEach>
                                    </c:if>
                                </p:submenu>
                            <p:menuitem value="Ödevlerim"  action="#{HomePageBean.clickMyHomeworks()}" update="sayfaalt" rendered="#{HomePageBean.logon==true and HomePageBean.userIsTeacher()==false}"/>
                            <p:menuitem rendered="#{HomePageBean.logon==true and HomePageBean.userIsTeacher()==true}" value="Duyuru Ekle"  action="#{HomePageBean.clickIndependentAddAnnounce()}" update="sayfaalt"/>
                            <p:menuitem rendered="#{HomePageBean.logon==true and HomePageBean.userIsTeacher()==true}" value="Ödev Ekle"  action="#{HomePageBean.clickNewHomework()}" update="sayfaalt"/>
                            <p:menuitem rendered="#{HomePageBean.logon==true and HomePageBean.userIsTeacher()==true}" value="Etkinlik Ekle"  action="#{HomePageBean.clickMyEvents()}" update="sayfaalt"/>
                        </p:menu>
                </h:column>
                  <h:column>
                      <p:panel rendered="#{HomePageBean.logon==true}" id="sayfaalt">
                        <ui:include src="#{HomePageBean.sayfaalt}"/>
                </p:panel>
                </h:column>
            </h:panelGrid>
    </h:form>
    </h:body>
    </f:view>
    <c:if test="#{HomePageBean.logon}"> 
        <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget() and CourseBean.coursesTeacher()}" widgetVar="newHomework" header="Yeni Ödev Ekle">
		<ui:include src="newHomework.xhtml"/>
	  </p:dialog>
	  <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget() and CourseBean.coursesTeacher()}" widgetVar="newAnnouncement" header="Yeni Duyuru Ekle">
		<ui:include src="newCourseAnnouncement.xhtml"/>
	  </p:dialog>
           <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget()}" widgetVar="students" header="Öğrenciler" height="500" width="500">
		<ui:include src="students.xhtml"/>
	  </p:dialog>
            <p:dialog dynamic="true" rendered="#{TeacherBean.checkTarget()}" widgetVar="mentoredStudents" header="Öğrenciler" height="500" width="500">
		<ui:include src="mentoredStudents.xhtml"/>
	  </p:dialog>
           <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget()}" widgetVar="homeworks" header="Ödevler" height="500" width="500">
		<ui:include src="homeworks.xhtml"/>
	  </p:dialog>
        <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget() and CourseBean.coursesTeacher()}" widgetVar="newEvent" header="Yeni Etkinlik Ekle">
		<ui:include src="newCourseEvent.xhtml"/>
	  </p:dialog>
	  <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget() and CourseBean.coursesTeacher()}" widgetVar="newMail" header="Yeni Mail Gönder">
		<ui:include src="newCourseMail.xhtml"/>
	  </p:dialog>
	  <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget()}" widgetVar="events" header="Dersin Takvimi">
              <h:form>
		<p:schedule widgetVar="schedule" view="basicWeek" value="#{CourseBean.eventModel}" locale="tr">
		    <p:ajax event="eventSelect" listener="#{CourseBean.onEventSelect}"  oncomplete="eventDialog.show();" /> 
		</p:schedule>
              </h:form>
              <p:dialog dynamic="true" widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">  
		    <h:form>
		<h:panelGrid id="eventDetails" columns="2">  
		    <h:outputLabel for="title" value="Bilgi:" />  
		    <p:inputText id="title" value="#{CourseBean.event.title}" required="true"/>  

		    <h:outputLabel for="to" value="Bitiş :" />  
		    <p:inputMask id="to" value="#{CourseBean.event.endDate}" mask="99/99/9999">  
			  <f:convertDateTime pattern="dd/MM/yyyy" />  
		    </p:inputMask>   
		    <p:commandButton rendered="#{CourseBean.coursesTeacher()}" value="Değiştir" actionListener="#{CourseBean.updateEvent}" oncomplete="schedule.update();eventDialog.hide();"/>  
		    <p:commandButton rendered="#{CourseBean.coursesTeacher()}" value="Etkinlik Oluştur" actionListener="#{CourseBean.addEvent2()}" oncomplete="schedule.update();eventDialog.hide();"/>
		</h:panelGrid>  
		    </h:form>
	  </p:dialog>  
	  </p:dialog>
        
        <p:dialog dynamic="true" rendered="#{CommunityBean.checkTarget()}" widgetVar="groupEvents" header="Grup Takvimi">
            <p:schedule widgetVar="schedule" view="basicWeek" value="#{CommunityBean.eventModel}" locale="tr">
		    <p:ajax event="eventSelect" listener="#{CourseBean.onEventSelect}"  oncomplete="eventDialog.show();" /> 
		    <p:ajax event="dateSelect" listener="#{CourseBean.onDateSelect}" oncomplete="eventDialog.show()" />  
		</p:schedule>
              <p:dialog dynamic="true" widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">  
		    <h:form>
		<h:panelGrid id="eventDetails" columns="2">  
		    <h:outputLabel for="title" value="Bilgi:" />  
		    <p:inputText id="title" value="#{CourseBean.event.title}" required="true"/>  

		    <h:outputLabel for="to" value="Bitiş :" />  
		    <p:inputMask id="to" value="#{CourseBean.event.endDate}" mask="99/99/9999">  
			  <f:convertDateTime pattern="dd/MM/yyyy" />  
		    </p:inputMask>   
		    <p:commandButton rendered="#{CourseBean.coursesTeacher()}" value="Değiştir" actionListener="#{CourseBean.updateEvent}" oncomplete="schedule.update();eventDialog.hide();"/>  
		    <p:commandButton rendered="#{CourseBean.coursesTeacher()}" value="Etkinlik Oluştur" actionListener="#{CourseBean.addEvent2()}" oncomplete="schedule.update();eventDialog.hide();"/>
		</h:panelGrid>  
		    </h:form>
	  </p:dialog>  
	  </p:dialog>
        <p:dialog dynamic="true" rendered="#{CommunityBean.checkTarget() and CommunityBean.communityAdmin()}" widgetVar="newComAnnouncement" header="Duyuru Ekle">
		<ui:include src="Community-addAnnounce.xhtml"/>
	</p:dialog>  
        <p:dialog dynamic="true" rendered="#{CommunityBean.checkTarget() and CommunityBean.communityAdmin()}" widgetVar="newComEvent" header="Etkinlik Ekle">
		<ui:include src="Community-addEvent.xhtml"/>
	</p:dialog>  
        <p:dialog dynamic="true" rendered="#{CommunityBean.checkTarget() and CommunityBean.communityAdmin()}" widgetVar="newComMail" header="Mail Gönder">
		<ui:include src="Community-sendMail.xhtml"/>
	</p:dialog>
        <p:dialog dynamic="true" rendered="#{CommunityBean.checkTarget()}" widgetVar="members" header="Grup Üyeleri" height="500" width="500">
		<ui:include src="Community-members.xhtml"/>
	  </p:dialog>
        <p:dialog dynamic="true" rendered="#{HomeworkBean.checkAnswer()==true and HomeworkBean.checkHomework()==true}" widgetVar="answer" header="Cevap">
		<ui:include src="answer.xhtml"/>
	  </p:dialog>
        
        <p:dialog dynamic="true" height="550" widgetVar="program" header="Ders Programı">
		<h:outputText escape="false" value="#{StudentBean.program}"/>
	  </p:dialog>
        
        <p:dialog dynamic="true" height="550" widgetVar="finalprogram" header="Final Programı">
            <h:outputText escape="false" value="#{StudentBean.studentFinalProgram()}"/>
	  </p:dialog>
        
        <p:dialog dynamic="true" rendered="#{CourseBean.checkTarget()}" height="550" widgetVar="announceExam" header="Sınav Açıkla">
            <ui:include src="announceExamResult.xhtml"/>
	  </p:dialog>
    </c:if>
</html>

